package com.sxx.beautifulcity.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sxx.beautifulcity.R;
import com.sxx.beautifulcity.entity.greendao.DaoMaster;
import com.sxx.beautifulcity.entity.greendao.Detail;
import com.sxx.beautifulcity.listenerInterface.OnDetailItemClickListener;

import org.w3c.dom.Text;

import java.util.List;

/**
 * Created by dllo on 15/11/9.
 */
public class StoreDetailAdapter extends RecyclerView.Adapter<StoreDetailAdapter.StoreDetailAdapterViewHolder> {

    public List<Detail> details;
    private OnDetailItemClickListener listener;


    public void addData(List<Detail> details) {
        this.details = details;
        notifyDataSetChanged();
    }

    public void setOnDetailItemClickListener(OnDetailItemClickListener listener) {
        this.listener = listener;
    }

    public StoreDetailAdapter(List<Detail> details) {
        this.details = details;
    }


    class StoreDetailAdapterViewHolder extends RecyclerView.ViewHolder{

        private TextView name;
        private int position;
        private RelativeLayout detail_relative;

        public StoreDetailAdapterViewHolder(View itemView) {
            super(itemView);
            name = (TextView) itemView.findViewById(R.id.store_name);
            detail_relative = (RelativeLayout) itemView.findViewById(R.id.detail_relative);
            //detail_relative.setOnClickListener(this);
     //       detail_relative.setOnLongClickListener(this);
        }

    }

    @Override
    public StoreDetailAdapterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.recycleview_detail_store, null);
        return new StoreDetailAdapterViewHolder(view);
    }

    @Override
    public void onBindViewHolder(StoreDetailAdapterViewHolder holder, int position) {
        holder.name.setText(details.get(position).getPath());
        holder.position = position;
    }

    @Override
    public int getItemCount() {
        return details != null && details.size() > 0 ? details.size() : 0;
    }

}
